Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't test issue-44056.rs on non-AVX hardware #55667

Closed
wants to merge 1 commit into from

Conversation

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 4, 2018
@infinity0
Copy link
Contributor Author

Actually I am unsure if that should be gate-test-avx_target_feature, apparently avx and avx512 are different. Please advise.

@nikic
Copy link
Contributor

nikic commented Nov 4, 2018

avx and avx512 are indeed different. However, I don't think that gate-test-* is the right thing to use here either way, as it's intended for testing feature gates, not to prevent the test from running if a hardware feature is unavailable. Unfortunately I don't know what the correct way to handle this is.

@nikic
Copy link
Contributor

nikic commented Nov 4, 2018

Actually, I'm wondering if this is even relevant anymore. This test has recently been moved to compile-pass, so it shouldn't try to execute it anymore and thus not require any particular hardware support. Looking at your logs, those builds happened when it was still a run-pass test.

On the other hand, looking at #44056 this test is supposed to test an issue that only occurs when the compiled binary is executed. Maybe it should not have been moved? /cc @RalfJung

@RalfJung
Copy link
Member

RalfJung commented Nov 4, 2018

Yeah maybe it should not have been moved, sorry. :/ Certainly won't do that again.

@@ -10,6 +10,7 @@

// compile-pass
// only-x86_64
// gate-test-avx512_target_feature
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gate-test is AFAIK used to indicate that this is a "feature gate test", to check the policy that every feature gate comes with a test making sure stuff is indeed gated.

You want some kind of only- annotation here to run the test only when certain conditions are met.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the syntax for "only"? I grep through the code and only see // only-$arch and it's not obvious where the docs for this stuff is...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only and ignore accept the same flags, maybe you can grep for ignore?

The code for this is at

fn parse_cfg_name_directive(&self, line: &str, prefix: &str) -> ParsedNameDirective {
. Maybe you need to add a way to control test execution based on CPU flags.

@eddyb
Copy link
Member

eddyb commented Nov 5, 2018

r? @alexcrichton

@@ -10,6 +10,7 @@

// compile-pass
Copy link
Contributor

@gnzlbg gnzlbg Nov 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is compile-pass, why is it being run ?

As in, we can cross-compile for x86_64 with avx from all x86_64 toolchains, and the tests checks that doing so works AFAICT, but this test shouldn't run.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the logs:

---- [ui] ui/run-pass/issues/issue-44056.rs stdout ----

it does appear that this test is in fact being run.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #55667 (comment). This test was recently moved to compile-pass (but should not have been, as the original issue requires execution).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, looking at the issue, this test does need execution. For that we would need a way to filter tests by target features available at run-time. Shouldn't be to hard to add a flag to prevent this tests from executing (e.g. using is_x86_feature_detected!("avx") ).

@alexcrichton
Copy link
Member

To make sure I'm getting this right, as pointed out by others the // gate-... directive doesn't actually prevent the test from running here (it's an unrelated directive) but it also looks like on master this test is no longer actually being run, it's just being compiled.

@infinity0 is the PR still needed in light of that information?

@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 5, 2018

@alexcrichton

but it also looks like on master this test is no longer actually being run, it's just being compiled.

This was an oversight and should be reverted (this test has to run), so this issue will still need fixing.

@infinity0
Copy link
Contributor Author

infinity0 commented Nov 6, 2018

@gnzlbg @alexcrichton

Yes this issue still needs fixing but the current PR is not approriate.

Indeed, looking at the issue, this test does need execution. For that we would need a way to filter tests by target features available at run-time. Shouldn't be to hard to add a flag to prevent this tests from executing (e.g. using is_x86_feature_detected!("avx") ).

I tried this, but this defeats the point of the test. The problem is that if you do something like

#![target_feature(enabled = "avx")]
fn main1() {}

fn main() { if is_x86_feature_detected!("avx") { main1() } }

no AVX instructions actually get generated and the original point of the test is defeated. The originally-problematic instructions (objdump -S $binary | grep ymm) are actually in the various panic handlers that are part of the std rust runtime. So defining specific functions as target_feature(enabled = "avx"), building the whole program by default without AVX, and conditionally calling the AVX-enabled functions at runtime is pointless, since the panic handlers still have no AVX instructions (and in fact the whole program has no AVX instructions since main1 is empty).

We basically need the test runner to conditionally run the whole program as a separate process, but ignore and only currently don't support this functionality and I'm not really familiar with the test harness to add this feature.

@RalfJung
Copy link
Member

RalfJung commented Nov 6, 2018

We do have a couple tests that use std::process to run the test as a separate process, e.g. to test that it exits with a particular signal (SEGFAULT, ...). Would that help?

@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 6, 2018

I tried this, but this defeats the point of the test.

@infinity0 Oh no, that's not what I meant! What I meant is to do run-time feature detection to decide whether the test must be run at all (from the parent process). The current test runner already has a lot of logic to decide when to run each test. So maybe we can add a // only-host-target-feature-avx comment that the test runner passes, and then, if the target_arch is x86_64, and the host where the test are run supports avx (which can be checked with the is_x86_feature_detected! macro in the test runner), only then we actually run this test.

FWIW, we don't have to implement a super-general system for running tests depending on the host target features right now. That is, it is fine to just "hack" something in the test runner that handles this case properly. If we ever need to do this again, we can consider improving the test runner further.

@alexcrichton
Copy link
Member

r? @gnzlbg

Sounds like y'all have a lot more opinions/thoughts about this than I

@Mark-Simulacrum
Copy link
Member

@gnzlbg Do you think you'll get a chance to make a review happen here soon?

@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 15, 2018

I think @infinity0 might have forgotten to close this. This tests was moved by mistake, so the issue this PR attempts to fix should not be happening any more.

@infinity0
Copy link
Contributor Author

The issue shouldn't be closed, it still exists. It's just now hidden by another bug (the incorrect move) so it won't be visible in current builds.

@RalfJung
Copy link
Member

RalfJung commented Nov 16, 2018

As of yesterday, I am still seeing this test fail when I do ./x.py test src/test/ui --test-args 44056. Let me see if I can still reproduce with current master.

@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 16, 2018

@infinity0 this is not an issue, its a PR, with a fix approach that won't fix the issue. Maybe you could open a proper issue for this?

@RalfJung due to the other bug @infinity0 mentions this test shouldn't currently ever run at all. If that reproduces, we should fill a second bug for this.

@RalfJung
Copy link
Member

Never mind, this was a case of #55537.

@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 16, 2018

I've opened this issue so that we don't forget about this: #55996

We should close this PR, revert the change that moved this test, and then send a PR that improves the test runner so that this test can be skipped if the hardware doesn't support AVX.

@infinity0
Copy link
Contributor Author

thanks, closing in favour of further discussion on issue #55996

@infinity0 infinity0 closed this Nov 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants